<%@ LANGUAGE="VBSCRIPT" %>
<%'  ------------------------------------------------------------
  '  mz_qspec.asp 
  '  ------------------------------------------------------------
  '  VCS INFO:
  '  
  '  $Revision:   1.19  $
  '  $Date:   04 May 1999 09:18:38  $
  '  $Author:   shsieh  $
  '  $Workfile:   mz_qspec.asp  $
  '  ------------------------------------------------------------
  '  All Rights Reserved.  Copyright (c) 1988-1998 FileNET Corp.
  '  ------------------------------------------------------------
  '%>
<!-- #include file="JScriptFix.asp" -->

<%
'Panagon IDM Web application uses the Session variable LibraryLogonID to keep track of
'whether the user has logged on.
'Please see logoncall.asp to see how the Session variable LibraryLogonID is set.
    LibraryLogonID = Session("LibraryLogonID")
    set LibraryObj = Server.CreateObject("IDMObjects.Library")
    LibraryObj.LogonID = LibraryLogonID
    set objClasses = LibraryObj.FilterClassDescriptions( Application("idmObjTypeDocument"))
%>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>

<head>
<meta http-equiv="Content-Type"
content="text/html">
<meta name="GENERATOR"
content="Microsoft FrontPage (Visual InterDev Edition) 2.0">
<title></title>
</head>

<body bgcolor="#FFFFFF">

<form name="search" action="mz_qresult.asp" method="POST" target="QueryResult">

<table>
<TR>
<TD>
<B><FONT SIZE=+1>Advanced Search</A></FONT></B>
<FONT > based on doctype </FONT>
</TD>
<TD>
<%
    ' the user is given the choice of going to an Advanced search page or 
    ' perform a simple search
%>
<select name="doctype" onChange="javascript:AdvancedSearch()">
            <option value="">&lt;Choose a type&gt;</option>
        <%
        ' enumerate through the defined DocTypes; the properties of the selected DocType
        ' are going to be displayed to enter the search criteria in the advanced search page
        for each objClass in objClasses%>
            <option value="<%=Server.URLEncode(objClass.Name)%>"><%=Server.HTMLEncode(objClass.Name)%></option>
        <%next%>
</select>
<TD>
</TR>
</table>
<hr>
    <input type="hidden" name="NewSearch" value="1">
    <input type="hidden" name="HiddenQueryCondition" value="">
<%
    ' Define the simple search fields
%>
    <B><FONT SIZE=+1>Simple Search</A></FONT></B>
    <table>
    <tr>
    <td><font color="#000080"><em><strong>Document ID : </strong></em></font> </td>
    <td><input type="text" size="9" name="ITEM_ID" value="" onBlur="CheckInteger(this)"> 
    </td>
    </tr>
    
    <tr>
    <td><font color="#000080"><em><strong>Title contains: </strong></em></font> </td>
    <td><input type="text" size="64" name="TITLE"> </td>
    </tr>
    
    <tr>
    <td><font color="#000080"><em><strong>Comment contains : </strong></em></font> </td>
    <td><input type="text" size="64" name="COMMENT"> </td>
    </tr>
    
    <tr>
    <td><font color="#000080"><em><strong>Added by user : </strong></em></font> </td>
    <td><input type="text" size="64" name="ADDED_BY_USER"> </td>
    </tr>
    
    <tr>
    <td><font color="#000080"><em><strong>Sort Order : </strong></em></font> </td>
    <td> <select name="SortBy">
    <option value="idmId" selected>Item ID
    <option value="idmName">Title
    <option value="idmDateAdded">Date Added
    </select>
    </td>
    </tr>

    </table>
    <a href="javascript:Submit()"><img alt="Search" src="images/sbutt.gif" align=bottom border=0 width=43 height=43></a><em><strong>Search</strong></em>
    <!-- or use the following
    <input type="submit" name="B1" value="  Search  ">
    -->
</form>
</body>
</html>

<!-- #include file="checkutil.asp" -->


<SCRIPT LANGUAGE=JavaScript>
<!--
// call the advanced search page 
function AdvancedSearch()
{
    docTypeStr = document.search.doctype.options[document.search.doctype.selectedIndex].value;
    parent.QueryResult.location.href = "blank.htm";
    location.href = "mz_advqspec.asp?doctype=" + docTypeStr;
    // location.href = "tools/debug.asp?doctype=" + docTypeStr;

}

function PagingMove(page)
{
location.href = "mz_qresult.asp?ResultID=<%=Session("ResultID")%>&Page=" + page;
}
//-->
</SCRIPT>


<SCRIPT LANGUAGE=JavaScript>
<!--
function substitute(string, match, replacement) {
  // Within STRING, replace any MATCHing string with the REPLACEMENT.
  var result = '';
  var index = 0;
  var lastIndex = index;
  while (string.length > lastIndex) {
    index = string.indexOf(match, lastIndex);
    if (index == -1) { break }
    result += string.substring(lastIndex, index) + replacement;
    lastIndex = index + match.length;
  }
  result += string.substring(lastIndex, string.length);
  return result;
}

// check the simple search criteria and execute the simple search
// by calling the mz_qresult.asp
function Submit()
{
    var prev = 0;
    var value = " ";
    // build the SQL statement from the inputed fields
    if (document.search.ITEM_ID.value) {
        value = value + "idmId=" + document.search.ITEM_ID.value;
        prev = 1;
    }
    if (document.search.TITLE.value) {
        if (prev)
            value = value + " and ";
        value = value + "idmName LIKE '%" + substitute(document.search.TITLE.value, "'", "''") + "%'";
        prev = 1;
    }
    if (document.search.COMMENT.value) {
        if (prev)
            value = value + " and ";
        value = value + "idmComment LIKE '%" + substitute(document.search.COMMENT.value, "'", "''") + "%'";
        prev = 1;
    }
    if (document.search.ADDED_BY_USER.value) {
        if (prev)
            value = value + " and ";
        value = value + "idmAddedByUser='" + substitute(document.search.ADDED_BY_USER.value, "'", "''") + "'";
        prev = 1;
    }
    if (prev == 0) {
        alert ("There is no search criteria specified.");   
    }
    else {
        sortStr = document.search.SortBy.options[document.search.SortBy.selectedIndex].value; 
        value = value + " ORDER BY " + sortStr; // document.search.SortBy.options[document.search.SortBy.selectedIndex].value
        document.search.HiddenQueryCondition.value = value;
        document.search.submit();
    }
}
//-->
</SCRIPT>